package com.ruoyi.eduManage.service.impl;

import java.util.List;
import java.util.Map;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.eduManage.domain.EduTeacher;
import com.ruoyi.eduManage.mapper.EduTeacherMapper;
import com.ruoyi.eduManage.service.IEduTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 教师信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-10-24
 */
@Service
public class EduTeacherServiceImpl implements IEduTeacherService
{
    @Autowired
    private EduTeacherMapper eduTeacherMapper;

    /**
     * 查询教师信息
     * 
     * @param teacherId 教师信息主键
     * @return 教师信息
     */
    @Override
    public EduTeacher selectEduTeacherByTeacherId(Long teacherId)
    {
        return eduTeacherMapper.selectEduTeacherByTeacherId(teacherId);
    }

    /**
     * 查询教师信息列表
     * 
     * @param eduTeacher 教师信息
     * @return 教师信息
     */
    @Override
    public List<EduTeacher> selectEduTeacherList(EduTeacher eduTeacher)
    {
        return eduTeacherMapper.selectEduTeacherList(eduTeacher);
    }

    /**
     * 新增教师信息
     * 
     * @param eduTeacher 教师信息
     * @return 结果
     */
    @Override
    public int insertEduTeacher(EduTeacher eduTeacher)
    {
        eduTeacher.setCreateTime(DateUtils.getNowDate());
        return eduTeacherMapper.insertEduTeacher(eduTeacher);
    }

    /**
     * 修改教师信息
     * 
     * @param eduTeacher 教师信息
     * @return 结果
     */
    @Override
    public int updateEduTeacher(EduTeacher eduTeacher)
    {
        eduTeacher.setUpdateTime(DateUtils.getNowDate());
        return eduTeacherMapper.updateEduTeacher(eduTeacher);
    }

    /**
     * 批量删除教师信息（逻辑删除）
     * 
     * @param teacherIds 需要删除的教师信息主键
     * @return 结果
     */
    @Override
    public int deleteEduTeacherByTeacherIds(Long[] teacherIds)
    {
        int rows = 0;
        for (Long teacherId : teacherIds)
        {
            rows += deleteEduTeacherByTeacherId(teacherId);
        }
        return rows;
    }

    /**
     * 删除教师信息信息
     * 
     * @param teacherId 教师信息主键
     * @return 结果
     */
    @Override
    public int deleteEduTeacherByTeacherId(Long teacherId)
    {
        EduTeacher eduTeacher = new EduTeacher();
        eduTeacher.setTeacherId(teacherId);
        eduTeacher.setDelFlag("1");
        eduTeacher.setUpdateTime(DateUtils.getNowDate());
        return eduTeacherMapper.updateEduTeacher(eduTeacher);
    }
    
    /**
     * 根据教师工号查询教师信息
     * 
     * @param teacherNo 教师工号
     * @return 教师信息
     */
    @Override
    public EduTeacher selectEduTeacherByTeacherNo(String teacherNo)
    {
        EduTeacher eduTeacher = new EduTeacher();
        eduTeacher.setTeacherNo(teacherNo);
        eduTeacher.setDelFlag("0");
        List<EduTeacher> list = eduTeacherMapper.selectEduTeacherList(eduTeacher);
        return list.size() > 0 ? list.get(0) : null;
    }
    
    /**
     * 获取教师班级打卡统计数据
     * 
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @return 统计数据列表
     */
    @Override
    public List<Map<String, Object>> getTeacherClassStatistics(String startDate, String endDate)
    {
        return eduTeacherMapper.getTeacherClassStatistics(startDate, endDate);
    }
}
